project (syncctl)

cmake_minimum_required (VERSION 2.6.2)
set (CMAKE_VERBOSE_MAKEFILE 1)
if (COMMAND cmake_policy)
    cmake_policy(SET CMP0003 NEW)
endif (COMMAND cmake_policy)

SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_SOURCE_DIR})

find_package(ODBC REQUIRED)

#SET(BISON_GENERATE_DEFINES TRUE)

#find_package(BISON REQUIRED)
#find_package(FLEX REQUIRED)
#find_package(LibArchive REQUIRED)

if(COVERAGE)
    SET(CMAKE_BUILD_TYPE debug)
    add_definitions(-g -O0 -ftest-coverage -fprofile-arcs)
    SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -ftest-coverage -fprofile-arcs")
    SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -ftest-coverage -fprofile-arcs")
endif(COVERAGE)

#bison_target(nodesconf_parser nodesconf.y ${CMAKE_CURRENT_BINARY_DIR}/nodesconf.tab.c COMPILE_FLAGS "-p nodesconf")
#flex_target(nodesconf_scanner nodesconf.lex ${CMAKE_CURRENT_BINARY_DIR}/nodesconf.yy.c COMPILE_FLAGS "-P nodesconf")
#add_flex_bison_dependency(nodesconf_scanner nodesconf_parser)
#add_library(nodesconf ${BISON_nodesconf_parser_OUTPUTS} ${FLEX_nodesconf_scanner_OUTPUTS})

#bison_target(syncconf_parser syncconf.y ${CMAKE_CURRENT_BINARY_DIR}/syncconf.tab.c COMPILE_FLAGS "-p syncconf")
#flex_target(syncconf_scanner syncconf.lex ${CMAKE_CURRENT_BINARY_DIR}/syncconf.yy.c COMPILE_FLAGS "-P syncconf")
#add_flex_bison_dependency(syncconf_scanner syncconf_parser)
#add_library(syncconf STATIC ${BISON_syncconf_parser_OUTPUTS} ${FLEX_syncconf_scanner_OUTPUTS})

#bison_target(packetinfo_parser packetinfo.y ${CMAKE_CURRENT_BINARY_DIR}/packetinfo.tab.c COMPILE_FLAGS "-p packetinfo")
#flex_target(packetinfo_scanner packetinfo.lex ${CMAKE_CURRENT_BINARY_DIR}/packetinfo.yy.c COMPILE_FLAGS "-P packetinfo")
#add_flex_bison_dependency(syncconf_scanner syncconf_parser)
#add_library(packetinfo ${BISON_packetinfo_parser_OUTPUTS} ${FLEX_packetinfo_scanner_OUTPUTS})

include_directories(${CMAKE_CURRENT_BINARY_DIR} ${PROJECT_SOURCE_DIR})
#add_executable(syncctl syncctl.c connect.c system.c node.c table.c data.c prepared.c updated.c packet.c)
#target_link_libraries(syncctl ${ODBC_LIBRARIES} syncconf packetinfo nodesconf)

add_executable(syncctl main.cpp Syncctl.cpp Syncconf.cpp Database.cpp Statement.cpp Column.cpp Param.cpp Packet.cpp Sqlerr.cpp)
target_link_libraries(syncctl ${ODBC_LIBRARIES})
target_link_libraries(syncctl debug gcov)

include(CTest)

add_test(SystemUninstall syncctl system uninstall)
add_test(SystemInstall syncctl system install)
add_test(SystemUpdate syncctl system update)
add_test(SystemStatus syncctl system status)
add_test(NodeAdd syncctl node add azs1)
add_test(NodeReset syncctl node reset azs1)
add_test(NodeRemove syncctl node remove azs1)
add_test(NodeList syncctl node list)
add_test(TableAdd syncctl table add public.mcs_sale)
add_test(TableUpdate syncctl table update public.mcs_sale)
add_test(TableRemove syncctl table remove public.mcs_sale)
add_test(TableDwatchOn syncctl table dwatch-on public.mcs_sale)
add_test(TableDwatchOff syncctl table dwatch-off public.mcs_sale)
add_test(DataPrepare syncctl data prepare for azs1)
add_test(DataUpdate syncctl data update from azs1)
add_test(PreparedSet syncctl prepared set 0 for azs1)
add_test(PreparedGet syncctl prepared get for azs1)
add_test(UpdatedSet syncctl updated set 0 for azs1)
add_test(UpdatedGet syncctl updated get for azs1)

set_tests_properties(SystemInstall SystemUninstall SystemStatus NodeAdd NodeReset NodeRemove NodeList TableAdd TableUpdate TableRemove TableDwatchOn TableDwatchOff DataPrepare DataUpdate PreparedSet PreparedGet UpdatedSet UpdatedGet PROPERTIES FAIL_REGULAR_EXPRESSION "ERROR")
set_tests_properties(SystemInstall SystemUninstall SystemStatus NodeAdd NodeReset NodeRemove NodeList TableAdd TableUpdate TableRemove TableDwatchOn TableDwatchOff DataPrepare DataUpdate PreparedSet PreparedGet UpdatedSet UpdatedGet PROPERTIES FAIL_REGULAR_EXPRESSION "unixODBC")
